package com.nsxy.manager.common.controllers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.UnauthenticatedException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 潜行的青衣
 * @see
 */
public class BaseBodyController extends BaseController {

	@Override
	@ResponseBody
	public String exception(HttpServletRequest request, HttpServletResponse response, Exception e) throws Exception {
		//未认证
        if(e instanceof UnauthenticatedException) {
        	return "{\"error\":401}";
        } else if(e instanceof UnauthorizedException) {
        	//没有权限
        	return "{\"error\":403}";
        }
        this.log.error("异常捕捉：", e);
        return "{\"error\":500}";  
	}

}
